package sivak.net.proc.recursion.hanoi_tower;

/**
 * Created with IntelliJ IDEA.
 * User: root
 * Date: 1/22/13
 * Time: 12:20 PM
 * To change this template use File | Settings | File Templates.
 */
import java.util.Stack;

public class Hanoi_q {
    public static void main(String[] args) {
        Stack<Integer> from = new Stack<Integer>();
        Stack<Integer> help = new Stack<Integer>();
        Stack<Integer> to = new Stack<Integer>();
        from.push(3);
        from.push(2);
        from.push(1);
        exchange(from, help, to, from.size());
        System.out.println(to.pop());
        System.out.println(to.pop());
        System.out.println(to.pop());
    }

    public static void exchange(
            Stack<Integer> from, Stack<Integer> help,
            Stack<Integer> to, int count) {
        if (count > 0) {
            exchange(from, to, help, count - 1);
            int biggest = from.pop();
            to.push(biggest);
            exchange(help, from, to, count - 1);
        }
    }
}
